package com.brp.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.brp.dao.CargoMapper;
import com.brp.po.Cargo;
import com.brp.po.Removecargo;
import com.brp.service.ICargoService;
import com.brp.service.IRemovecargoService;
import com.brp.service.ISaleService;
import com.brp.vo.ResultVo;
import com.brp.vo.SaleVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author all
 * @since 2022-03-16
 */
@RestController
@RequestMapping("/sale")
public class SaleController {
    @Autowired
    private ISaleService saleService;

    @RequestMapping({"/allCargo/{pageNo}/{pageSize}"})
    @ResponseBody
    public ResultVo<Cargo> getAllCargo(@PathVariable("pageNo")Integer pageNo,@PathVariable("pageSize")Integer pageSize){
        System.out.println(pageNo + "  " + pageSize);
        ResultVo<Cargo> allCargo = saleService.getAllCargo(1, 2);
        return allCargo;
    }

    @RequestMapping("/oneCargo/{cargoName}/{cargoType}")
    @ResponseBody
    public ResultVo<Cargo> getOneCargo(@PathVariable("cargoName")String cargoName, @PathVariable("cargoType")String cargoType){
        ResultVo<Cargo> oneCargo = saleService.getOneCargo(cargoName, cargoType);
        return oneCargo;
    }

    @RequestMapping("/addRemoveCargo/{cargoId}")
    public boolean addRemoveCargo(@PathVariable("cargoId")Integer cargoId){
        boolean b = saleService.addRemoveCargo(cargoId);
        return b;
    }

    @RequestMapping("/deleteRemoveCargo/{id}")
    public boolean deleteRemoveCargo(@PathVariable("id")Integer id){
        boolean b = saleService.deleteRemoveCargo(id);
        return b;
    }

    @RequestMapping("/deleteRemoveCargoAll")
    public boolean deleteRemoveCargoAll(SaleVo saleVo){
        boolean b = saleService.deleteRemoveCargoAll(saleVo);
        return b;
    }

    @RequestMapping("/updateNumber/{number}")
    public boolean updateNumber(@PathVariable("number")Integer number){
        boolean b = saleService.updateNumber(number);
        return b;
    }

}
